// pages/essence_knowledge/essence_knowledge.js
Page({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    nav_show:false,
    nav_title:'知识精华',
    fontColor:'#ffffff',
    // 公告列表
    list_notice:[{title:"公告公告公告公告公告公告公告公告公告公告公告公告公告公告"}],
    active: 0,
    list_tabbar:[
      {id:'0',name:'全部'},
      {id:'1',name:'产品教学'},
      {id:'2',name:'舌象'},
      {id:'3',name:'真艾养生'},
      {id:'4',name:'每日一膳'},
      {id:'5',name:'找美食'},
      {id:'6',name:'7777'},
    ],
    count:'',
    list_detail:[],
    list_detail_data:[
      {id:'0',type_name:'产品教学',title:'产品教学标题1',imgurl:'../../static/essence_knowledge/notice_icon.png',content:'产品教学',isfrom:'产品教学来源1'},
      {id:'1',type_name:'舌象',title:'舌象标题',imgurl:'../../static/essence_knowledge/notice_icon.png',content:'舌象',isfrom:'舌象来源1'},
      {id:'2',type_name:'真艾养生',title:'真艾养生标题1”',imgurl:'../../static/essence_knowledge/notice_icon.png',content:'真艾养生',isfrom:'真艾养生来源1'},
      {id:'3',type_name:'每日一膳',title:'每日一膳标题1”',imgurl:'../../static/essence_knowledge/notice_icon.png',content:'每日一膳',isfrom:'每日一膳来源1'},
      {id:'4',type_name:'找美食',title:'找美食标题1”',imgurl:'../../static/essence_knowledge/notice_icon.png',content:'找美食',isfrom:'找美食来源1'},
      {id:'5',type_name:'产品教学',title:'产品教学标题2”',imgurl:'../../static/essence_knowledge/notice_icon.png',content:'产品教学2',isfrom:'产品教学来源2'},
      {id:'6',type_name:'舌象',title:'舌象标题2”',imgurl:'../../static/essence_knowledge/notice_icon.png',content:'舌象2',isfrom:'舌象来源2'},
      {id:'7',type_name:'真艾养生',title:'真艾养生标题2”',imgurl:'../../static/essence_knowledge/notice_icon.png',content:'真艾养生2',isfrom:'真艾养生来源2'},
      {id:'8',type_name:'每日一膳',title:'每日一膳标题2”',imgurl:'../../static/essence_knowledge/notice_icon.png',content:'每日一膳2',isfrom:'每日一膳来源2'},
      {id:'9',type_name:'找美食',title:'找美食标题2”',imgurl:'../../static/essence_knowledge/notice_icon.png',content:'找美食2',isfrom:'找美食来源2'},
    ]
  },
  onLoad: function (options) {
    // 页面加载时执行的代码
    let list_detail_data = JSON.parse(JSON.stringify(this.data.list_detail_data))
    this.setData({
      list_detail:list_detail_data
    })
  },
  /**
   * 组件的方法列表
   */

    onChange(event) {
      let list_detail_data = JSON.parse(JSON.stringify(this.data.list_detail_data))
      this.setData({
        list_detail:[]
      })
      if(event.detail.name=='0'){
        this.setData({
          list_detail:list_detail_data
        })
      }
      if(event.detail.name==this.data.list_tabbar[event.detail.name].id){
        for(var i=0;i<list_detail_data.length;i++){
          if(list_detail_data[i].type_name==this.data.list_tabbar[event.detail.name].name){
            this.data.list_detail.push(list_detail_data[i])
            this.setData({
              list_detail:this.data.list_detail
            })
          }
        }
      }
  
  },
  To_knowledge_detail(e){
    console.log(e.currentTarget.id)
    let kind = e.currentTarget.id
    wx.navigateTo({
      url: '../knowledge_detail/knowledge_detail?kind='+kind
    }); 
  }
})
